#include <bits/stdc++.h>
// 2025/07/21
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, m, cnt, g[51][51], parents[2501], sz[2501];

class UF {
public:
    UF(int n)
    {
        cnt = n;
        for (int i = 1; i <= n; i++)
            parents[i] = i, sz[i] = 1;
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        if (sz[ri] < sz[rj])
            swap(ri, rj);
        parents[rj] = ri;
        sz[ri] += sz[rj];
        cnt--;
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> m >> n;
    UF uf(m * n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> g[i][j];
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if (!(g[i][j] & 1))
                uf.un((i - 1) * m + j, (i - 1) * m + j - 1);
            if (!(g[i][j] & 2))
                uf.un((i - 1) * m + j, (i - 2) * m + j);
            if (!(g[i][j] & 4))
                uf.un((i - 1) * m + j, (i - 1) * m + j + 1);
            if (!(g[i][j] & 8))
                uf.un((i - 1) * m + j, i * m + j);
        }
    }
    cout << cnt << endl;
    int maxroom = 0;
    for (int i = 1; i <= n * m; i++)
        maxroom = max(maxroom, sz[i]);
    cout << maxroom << endl;
    int maxsize = maxroom, x = 0, y = 0, type = 0;
    for (int j = 1; j <= m; j++)
        for (int i = 2; i <= n; i++) {
            int ri = uf.find((i - 1) * m + j), rj = uf.find((i - 2) * m + j);
            if (ri != rj) {
                int t = sz[ri] + sz[rj];
                if (t > maxsize || (t == maxsize && (j < y || (j == y && i > x))))
                    maxsize = t, x = i, y = j, type = 0;
            }
        }
    for (int j = 1; j < m; j++)
        for (int i = 1; i <= n; i++){
            int ri = uf.find((i - 1) * m + j), rj = uf.find((i - 1) * m + j + 1);
            if (ri != rj){
                int t = sz[ri] + sz[rj];
                if (t > maxsize || (t == maxsize && (j < y || (j == y && i > x))))
                    maxsize = t, x = i, y = j, type = 1;
            }
        }
    cout << maxsize << endl;
    cout << x << " " << y << " " << (type ? "E" : "N") << endl;
    return 0;
}